<?php
/**
 * Magento Enterprise Edition
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Magento Enterprise Edition End User License Agreement
 * that is bundled with this package in the file LICENSE_EE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.magento.com/license/enterprise-edition
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     rwd_enterprise
 * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
 * @license http://www.magento.com/license/enterprise-edition
 */
?>
<?php
    $wishlistItems = $this->getWishlistItems();
?>
<div class="page-title title-buttons">
    <?php if ($this->helper('wishlist')->isRssAllow() && count($this->getWishlistItems())): ?>
        <a href="<?php echo $this->helper('wishlist')->getRssUrl($this->getWishlistInstance()->getId()); ?>" class="link-rss"><?php echo $this->__('RSS Feed') ?></a>
    <?php endif; ?>
    <h1><?php echo $this->__('Wishlist Info') ?></h1>
</div>
<?php echo $this->getMessagesBlock()->toHtml(); ?>
<div class="info-box">
    <div class="box-content">
        <table class="info-table">
            <col width="1" />
            <col />
            <tbody>
                <tr>
                    <th><span class="nobr"><?php echo $this->__('Owner'); ?></span></th>
                    <td><?php echo $this->escapeHtml($this->getWishlistOwner()->getName()); ?></td>
                </tr>
                <tr>
                    <th><span class="nobr"><?php echo $this->__('Name'); ?></span></th>
                    <td><?php echo $this->escapeHtml($this->getWishlistInstance()->getName()); ?></td>
                </tr>
                <tr>
                    <th><span class="nobr"><?php echo $this->__('Updated at'); ?></span></th>
                    <td><?php echo $this->formatDate($this->getWishlistInstance()->getUpdatedAt(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM); ?></td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

<h2 class="subtitle"><?php echo $this->__('Wishlist Items') ?></h2>
<form method="post" action="<?php echo $this->getToCartUrl(); ?>" id="wishlist-info-form">
    <?php echo $this->getBlockHtml('formkey') ?>
    <?php $this->getChild('items')->setItems($this->getWishlistItems()); ?>
    <?php echo $this->getChildHtml('items'); ?>
    <?php if (count($wishlistItems) && $this->isSaleable()): ?>
        <div class="buttons-set buttons-set2">
            <button type="submit" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-add"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
        </div>
    <?php endif; ?>
</form>
<script type="text/javascript">
//<![CDATA[
    (function() {
        var form = $('wishlist-info-form');
        var itemsSelected = function() {
            var selected = false;
            $(form).select('input.select').each(function(item) {
                if ($(item).checked) {
                    selected = true;
                }
            });
            return selected;
        };
        var validation = new Validation(form, {
            onFormValidate : function(result, elm) {
                form.isValid = result;
            }
        });
        Event.observe(form, 'submit', function(event) {
            if (form.isValid && !itemsSelected()) {
                Event.stop(event);
                alert('<?php echo Mage::helper('core')->jsQuoteEscape($this->__('You must select items to add to cart')); ?>');
            }
        });
    })();
//]]>
</script>
<div class="buttons-set">
    <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
</div>
